package cz.schovjan.proj.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * Tovarna pro SessionFactory vraci singleton.
 * Pouziva se v Advice pro odesilani emailu adminum.
 * @author schovjan
 * 
 */
public class HibernateUtil {
	private static final SessionFactory sessionFactory;

	static {
		try {
			// SessionFactory ze souboru hibernate.cfg.xml, pouzivat
			// AnnotationConfiguration
			sessionFactory = new AnnotationConfiguration().configure()
					.buildSessionFactory();
		} catch (Throwable ex) {
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	
}
